package com.zyd.databindingdemo;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.os.Bundle;

import com.zyd.databindingdemo.databinding.ActivityMainBinding;

/**
 * 绑定表达式
 * 值绑定
 */
public class MainActivity extends AppCompatActivity {
    ActivityMainBinding activityMainBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activityMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        Person person = new Person();
        person.name = "小明";
        person.age = 18;
        String content = "名片";
        boolean enable = false;

        activityMainBinding.setPerson(person);
        activityMainBinding.setContent(content);
        activityMainBinding.setEnabled(enable);
    }
}